/**
 * ImageFileFilter.java
 * 
 * @date: 2012-02-15
 * @author: Xiaoyu Guo (MUN# 200982155)
 * This file is part of the course project for COMP 6752, 
 * Application of Computer Graphics. All the file is written
 * by myself.
 */
package mun.cs6752.project.ui.fileChooser;

import java.io.File;

import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

/**
 * @author Xiaoyu Guo
 *
 */
public class ImageFileFilter{
    public final static String FILE_EXTENSION_JPEG  = "jpeg";
    public final static String FILE_EXTENSION_JPG   = "jpg";
    public final static String FILE_DESCPTION_JPEG  = "JPEG File (.jpg)";
    public final static String FILE_EXTENSION_GIF   = "gif";
    public final static String FILE_DESCPTION_GIF   = "GIF File (.gif)";
    public final static String FILE_EXTENSION_TIFF  = "tiff";
    public final static String FILE_EXTENSION_TIF   = "tif";
    public final static String FILE_DESCPTION_TIFF  = "TIFF File (.tiff)";
    public final static String FILE_EXTENSION_PNG   = "png";
    public final static String FILE_DESCPTION_PNG   = "PNG File (.png)";
    public final static String FILE_EXTENSION_BMP   = "bmp";
    public final static String FILE_DESCPTION_BMP   = "BMP File (.bmp)";
    
    public final static String getExtension(File f){
        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
    
    public final static FileFilter[] FILE_FILTERS = new FileFilter[]{
        new FileNameExtensionFilter(FILE_DESCPTION_JPEG, FILE_EXTENSION_JPG),
        new FileNameExtensionFilter(FILE_DESCPTION_GIF,  FILE_EXTENSION_GIF),
        new FileNameExtensionFilter(FILE_DESCPTION_TIFF, FILE_EXTENSION_TIF),
        new FileNameExtensionFilter(FILE_DESCPTION_PNG,  FILE_EXTENSION_PNG),
        new FileNameExtensionFilter(FILE_DESCPTION_BMP,  FILE_EXTENSION_BMP)
    };
}
